package com.smh.a01InetAddressDemo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressDemo1 {
    public static void main(String[] args) throws UnknownHostException {


        //获取InetAddress对象
        InetAddress address = InetAddress.getByName("192.168.175.168");
        System.out.println(address);
        InetAddress address1 = InetAddress.getByName("LAPTOP-CUFU4A90");
        System.out.println(address1);
        //如果网路不好,可能会返回ip
        System.out.println(address1.getHostName());
        System.out.println(address1.getHostAddress());

    }
}
